package serializable.jaxb;

import java.io.File;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;

import serializable.testdata.DataObject;

public class Context {

	static final String PACKAGE = DataObject.class.getPackage().getName();
	public DataObject obj;

	public Context(DataObject dataObj, File file) throws JAXBException {
		System.out.println(PACKAGE);
		JAXBContext jc = JAXBContext.newInstance(PACKAGE);
		Marshaller m = jc.createMarshaller();
		m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
		Unmarshaller um = jc.createUnmarshaller();
		m.marshal(dataObj, file);
		this.obj = (DataObject) um.unmarshal(file);

	}

}
